import java.util.*;

/**
 * @author LKQ
 * @date 2022/6/11 10:02
 * @description 需要注意到ipv4是一个256进制的数，4段，每段占8个字节，2^8, ipv6 为8段，每段占16个字节， 2^16次方
 */
public class Solution {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextLine()) {
            String ipToNumber = sc.nextLine();
            long numberToIp = Long.parseLong(sc.nextLine());
            System.out.println(ipToNum(ipToNumber));
            System.out.println(numToIp(numberToIp));
        }
    }
    public static long ipToNum(String s) {
        String[] ips = s.split("\\.");
        StringBuilder sb = new StringBuilder();
        long ans = 0;
        for (int i = 0; i < 4; i++) {
            ans = ans * 256 + Integer.parseInt(ips[i]);
        }
        return ans;
    }
    public static String numToIp(long n) {
        String result = "";
        for (int i = 0; i < 4; i++) {
            result = n % 256 + "." + result;
            n /= 256;
        }
        return result.substring(0, result.length() - 1);
    }
}
